﻿#region

using System;
using Domain;
using Domain.Algorithms;

#endregion

namespace Presentation {
    public class MainUseCase {
        private IMainView MainView { get; set; }

        public MainUseCase(IMainView mainView) {
            MainView = mainView;
            mainView.BuildDecompositionTree = BuildDecompositionTree;
            //mainView.HyperGraph = new PEHyperGraph("9\r\n5\r\n0 1 5 6 \r\n2 6 \r\n3 6 7 \r\n3 4 8 \r\n3 4 7 \r\n"); // М-Ацикличесикй граф
            mainView.HyperGraph = new PEHyperGraph("16\r\n7\r\n0 1 2 3 4 5 \r\n5 6 7 \r\n4 6 8 \r\n7 8 9 10 11 12 \r\n13 15 \r\n14 15 \r\n12 13 14 \r\n"); // М-Цикличесикй граф
//16
//7
//0   1   2   3   4   5   
//5   6   7   
//4   6   8   
//7   8   9   10   11   12   
//13   15   
//14   15   
//12   13   14   
        }

        private void BuildDecompositionTree() {
            var hyperGraph = MainView.HyperGraph.DomainObject;

            var tree = DecompositionTreeBuilder.BuildDecompositionTree(hyperGraph);
            MainView.DecompositionTree = new PEGraph(tree);
        }
    }
}